/*
C: The Complete Reference, 4th Ed. (Paperback)
by Herbert Schildt

ISBN: 0072121246
Publisher: McGraw-Hill Osborne Media; 4 edition (April 26, 2000)
*/

#include <string.h>
#include <stdio.h>
#include <stdlib.h>

void shellsort(char *words, int arraysize);

int main(void){
	
  char s[255];

  printf("Enter a string:");
  gets(s);
  shellsort(s, strlen(s));
  printf("The sorted string is: %s.\n", s);

  return 0;
}
/* . */
void shellsort(char *words, int arraysize){

	int i, j, k, gap=0;
	int a[5]={9, 5, 3, 2, 1};
	char x='\0';

	for(k=0; k < 5; k++) {
		gap = a[k];
		for(i=gap; i < arraysize; ++i) {
			x = words[i];
			for(j=i-gap; (x < words[j]) && (j >= 0); j=j-gap)
				words[j+gap] = words[j];
			words[j+gap] = x;
		}
	}
}
